﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PluginInterface;

namespace Calculadora
{
    public partial class Form1 : Form

    {
        Metodos met;
        public Form1()
        {
            met = new Metodos();
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {   
            met.cargarPlugins();
            comboBox1.Text = "Seleccione Opción";
            textBox2.Enabled = false;
            comboBox1.Enabled = false;
            label1.Text = "";
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            foreach(Plugin p in met.getListaPlugins())
            {
                comboBox1.Items.Add(p.Nombre);
           
            }
            if (comboBox1.Items.Count != 0)
                comboBox1.SelectedIndex = 0;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            label1.Text = met.resultadoPlugin(textBox1.Text, textBox2.Text, comboBox1.Text);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            met.cargarPlugins();
            comboBox1.Items.Clear();
            comboBox1.Text = "Seleccione Opción";
            label1.Text = "";
            foreach (Plugin p in met.getListaPlugins()) {
                comboBox1.Items.Add(p.Nombre);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            comboBox1.Text = "Seleccione Opción";
            textBox2.Enabled = true;
            label1.Text = "";
            if ((textBox1.Text == "") || (textBox2.Text == "")) { comboBox1.Enabled = false; }
            else { comboBox1.Enabled = true; }

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            comboBox1.Text = "seleccione Opcion";
            comboBox1.Enabled = true;
            label1.Text = "";
            if ((textBox1.Text == "") || (textBox2.Text == "")) { comboBox1.Enabled = false; }
            else { comboBox1.Enabled = true; }
        }

        
    
    

    
    
    
    
    
    
    }
}
